// @ts-nocheck
import React, { useEffect, useState } from "react";
import { NavBar } from "antd-mobile";
import { useNavigate } from "react-router-dom";
import "./index.less";
import { getCurrentUserInfo } from "@/utils/authority";
import { replyList } from "../../service";


const CommunityReply: React.FC<any> = () => {
	const navigate = useNavigate();
	const userId = getCurrentUserInfo()?.data?.id;


	const [list, setList] = useState<any>([]);
	const getListData = async () => {
		const params = {
			userId: userId,
		};
		try {
			const { data } = await replyList(params);
			setList( data?.records || [] );

		} catch {}
	};

	useEffect(() => {
		getListData();
	}, []);

	return (
		<div className="communityReply-contarnier">
			<div className="header">
				<div>
					<NavBar onBack={() => navigate("/user/trends")}>
						<div className="commontitle">社区回复</div>
					</NavBar>
				</div>
			</div>
			<div className="communityReply-box">
				{list.map((item) => (
					<div
						className="communityReply-box-card"
						key={item.id}
						onClick={() => navigate("/user/trends/communityReplyDetails", { state: item })}>
						<div className="communityReply-box-card-title">{item?.title}</div>
						<div className="communityReply-box-card-type">
							<span>{item?.type}</span>
						</div>
						<div className="communityReply-box-card-time">{item?.initiationTime}</div>
						<div className="ysl">已回复</div>
					</div>
				))}
			</div>
		</div>
	);
};

export default CommunityReply;
